{*
  Object Pascal simple geometric routines
  @Author  Maciej Zagozda (1998-2008)
  @Licence Microsoft Reciprocal License (Ms-RL)
  @Website http://www.codeplex.com/intelitechdelphirtns/
  @Version 2008/04/20 Added documentation support
  @version 2008/05/16 Added PointsDistance function
}

unit GeometricRoutines;

interface

uses
  Windows,
  Classes,
  Dialogs,
  Graphics,
  Messages,
  Printers,
  SysUtils;

function CylinderArea( singRadius, singHeight: Single ): Extended;
function CylinderVolume( singRadius, singHeight: Single ): Extended;
function PointsDistance(const aPoint1, aPoint2: TPoint) : Double;
function SphereArea( singRadius: Single ): Extended;
function SphereVolume( singRadius: Single ): Extended;

implementation

function CylinderArea( singRadius, singHeight : Single ): Extended;
begin
  Result := (2 * PI * singRadius * singHeight );
end;

function CylinderVolume( singRadius, singHeight: Single ): Single;
begin
  Result := ( PI * singRadius * singRadius * singHeight );
end;

{*
  Calculates distance between two points
  @param aPoint1 - Point 1 specified as of TPoint type
  @param aPoint2 - Point 1 specified as of TPoint type
  @return Distance in Pixels, expressed as Double
*}

function PointsDistance(const aPoint1, aPoint2: TPoint) : Double;
var
  dx : LongInt;
  dy : LongInt;
begin
  dx := aPoint1.x - aPoint2.x;
  dy := aPoint1.y - aPoint2.y;
  Result := Sqrt((Dx * Dx) + (Dy * Dy));
end;

function SphereArea( singRadius: Single );
begin
  Result := ( 4 * PI * singRadius * singRadius );
end;

function SphereVolume( singRadius: Single );
begin
  Result := (( 4 / 3 ) * PI * singRadius * singRadius * singRadius );
end;
end.
